#ifndef COMPILE_LLVM_H
#define COMPILE_LLVM_H

#include <stack>
#include <string>
#include <map>

#define __STDC_LIMIT_MACROS 1
#define __STDC_CONSTANT_MACROS 1
#include <llvm/Module.h>
#include <llvm/LLVMContext.h>

#include "CompileVisitor.h"
#include "Ast.h"

class CompileLlvm : public CompileVisitor
{
  public:
    CompileLlvm(const char * output);

    virtual int finalize();

    virtual int compile(AstNodeLiteral *);
    virtual int compile(AstNodeStatementList *);
    virtual int compile(AstNodeLValue*);
    virtual int compile(AstNodeBooleanOperator *);
    virtual int compile(AstNodeAssignment *);
    virtual int compile(AstNodeExpressionVariable *);
    virtual int compile(AstNodeDoubleConstant *);
    virtual int compile(AstNodeBinaryOperator *);
    virtual int compile(AstNodeCompareExpression *);
    virtual int compile(AstNodeForStatement *);
    virtual int compile(AstNodeIfStatement *);
    virtual int compile(AstNodePrintLiteral *);
    virtual int compile(AstNodePrintExpression *);
  private:
    llvm::LLVMContext &Context;
    llvm::Module *     module;
    llvm::Function *   function;

    std::stack<llvm::Value*> blockStack;
    std::map<std::string, llvm::Value*> NamedValues;
};
#endif

